<div class='sb-ci-w ttc-lt-w font-body nospacing' id='category-list'>
	<?php $parentCount = count($model);foreach ($model as $key=>$one):?>
	<?php 
		$data = $one->descendants; 
		$ids = CHtml::listData($data, 'id', 'id');
		$hover = 'hover';
		if ($native->type_id != $one->id) {
			if (!in_array($native->type_id, $ids)) {
				$hover = '';
			}
		}
	?>
	<div class='item  <?php echo $hover; echo $key+1 == $parentCount ? ' last' : ''?>'>
		<?php echo LyscHtml::buttonList(
			$form, $native, 'type_id', 
			array($one->id=>$one->name)
			, array(
				'tagName' => 'em',
				'itemTemplate' => '<h3 key="{key}"><b></b><a href="javascript:void(0)" class="bh-font14">{value}</a><span>('.$one->count.')</span></h3>'
			)
		)?>
		<ul>
			<?php $children = $one->descendants; foreach($children as $key => $one):?>
				<?php 
					$class = count($children) == $key+1 ? 'class="tree-last"' : '';
					$data = array($one->id => $one->name);
					echo LyscHtml::buttonList(
					$form, $native, 'type_id', $data, array(
							'tagName' => 'li',
							'clearfix' => false,
							'itemTemplate' => '<span key="{key}"><s '.$class.'></s><a href="javascript:void(0)">{value}</a><span>('.$one->count.')</span></span>'
						)
						
					);
				?>
			
			<?php endforeach;?>
		</ul>
	</div>
	<?php endforeach;?>
</div>
<script>
$().ready(function() {
	// 展开，最后一个节点的样式。
	$('#category-list .item b').click(function(e) {
		that = $(this);
		if($(this).closest('div.item').hasClass('hover')) {
			$(this).closest('div.item').find('ul').slideUp('fast', function() {
				$(this).closest('div.item').removeClass('hover');
			});
		} else {
			$(this).closest('div.item').find('ul').slideDown('fast', function() {
				$(this).closest('div.item').addClass('hover');
			});
		}
		stopBubble(e);
		stopDefault(e);
		return false;
	});
});
</script>